using UnityEngine;

public class WaterSwimInDetect : MonoBehaviour
{
    public bool isObjectInWater;
    public Transform transform;
    public Rigidbody2D rb;

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("pitfall"))
        {
            isObjectInWater = true;
            rb = other.gameObject.GetComponent<Rigidbody2D>();
            transform = other.gameObject.transform;
        }
    }

    private void OnTriggerExit2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("pitfall")) isObjectInWater = false;
    }
}